#ifndef MAINFORM_H
#define MAINFORM_H

#include <QtGui/QWidget>
#include <QMessageBox>
#include <QTextStream>
#include <QTreeWidget>
#include <QDomDocument>

#include "txtform.h"
#include "progressform.h"
#include "htmlform.h"
#include "firstwidget.h"
#include "csvform.h"
#include "finishform.h"
#include "previewForm.h"

class QTreeWidgetItem;

namespace Ui {
    class mainForm;
}

class mainForm : public QDialog {
    Q_OBJECT
public:
    mainForm(QWidget *parent = 0);
    ~mainForm();

    void setTreeWidget( QTreeWidget * );

signals:
    void stepMade(int);

protected:
    void changeEvent(QEvent *e);

private:
    Ui::mainForm *m_ui;

    int total;
    int progress;
    QTreeWidget * treeWidget;

    firstWidget * fW;
    txtForm * txtW;
    csvForm * csvW;
    htmlForm * htmW;
    progressForm * prgW;
    finishForm * finW;
    previewForm * prView;

    QString fileName;
    QHash<QTreeWidgetItem *, QDomElement> domElementList;

    void saveToFile( QString&, int );

    void save_to_txt_file( QString &, int );
    void save_to_xml_file( QString &, int );
    void save_to_csv_file( QString &, int );
    void save_to_html_file( QString &, int );
    int getParentCount( QTreeWidgetItem * );
    bool isItemFolder( QTreeWidgetItem * );

    void fillPreview();

private slots:
    void on_prevButton_clicked();
    void on_cancelButton_clicked();
    void on_nextButton_clicked();
};

#endif // MAINFORM_H
